package org.example.completed.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;
import org.example.completed.domain.Reservation;

import java.util.List;

@Mapper
public interface ReservationMapper {

    // 添加预约
    @Insert("INSERT INTO reservation(name, contact, visit_time) VALUES(#{name}, #{contact}, #{visitTime})")
    void addReservation(Reservation reservation);

    // 获取所有预约信息
    @Select("SELECT id, name, contact, visit_time, created_at FROM reservation")
        // 增加类型强
        @Result(property = "visitTime", column = "visit_time")
        @Result(property = "createdAt", column = "created_at")
    List<Reservation> getAllReservations();
}
